<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>评审专家信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		function subForm(){
			var flag = false;
			if($("#exName").val() == '' || $("#exName").val() == null){
				top.$.jBox.tip("请输入专家名称", 'info');
				return false;
			}
			
			if($("#card").val() != null && $("#card").val() != ''){
				if(!checkIdcard($("#card").val())){
					top.$.jBox.tip("请输入正确的身份证号码", 'info');
					return false;
				}
			}else{
				top.$.jBox.tip("请输入身份证号码", 'info');
				return false;
			}
			
			if($("#expertsTypeId").val() == '' || $("#expertsTypeId").val() == null){
				top.$.jBox.tip("请选择专家分类", 'info');
				return false;
			}
			
			if($("#bep").val() == '' || $("#bep").val() == null){
				top.$.jBox.tip("请填写评标专业", 'info');
				return false;
			}
			
			if($("#positional").val() == '' || $("#positional").val() == null){
				top.$.jBox.tip("请填写职称", 'info');
				return false;
			}
			
			
			if($("#phone").val() == '' || $("#phone").val() == null){
				top.$.jBox.tip("请填写手机号码", 'info');
				return false;
			}
			
			
			
			if($("#evaluateGrade").val() == '' || $("#evaluateGrade").val() == null){
				top.$.jBox.tip("请选择专家评价", 'info');
				return false;
			}
			
			if($("#evaluateContent").val() == '' || $("#evaluateContent").val() == null){
				top.$.jBox.tip("请填写评价内容", 'info');
				return false;
			}
			
			$.ajax({
                cache: true,
                type: "POST",
                url:"${ctx}/zx/proExperts/saveExertsInfo",
                data:$('#addProExertsForm').serialize(),// 
                async: false,
                error: function(XMLHttpRequest) {
                	top.$.jBox.tip("表单提交异常", 'info');
                },
                success: function(data) {
                	if(data == '1'){
                		top.$.jBox.tip("该专家已存在，请勿重复添加", 'info');
                	}else{
                		top.$.jBox.tip("专家信息保存成功", 'info');
                		flag = true;
                	}
                	
                }
            });
			return flag;
		}
		
		$(document).ready(function() {
			$("#card").blur(function(){
				var card = $(this).val();
				if(checkIdcard(card)){
					// 根据身份证号码，查询是否存在相同的人
					$.ajax({
		                cache: true,
		                type: "POST",
		                url:"${ctx}/zx/proExperts/getExpertsInfo?card=" + card,
		                //async: false,
		                error: function(XMLHttpRequest) {
		                	top.$.jBox.tip("数据请求异常", 'info');
		                },
		                success: function(data) {
		                	//debugger;
		                	if(data != null && data != ''){
		                		$("#id").val(data.id);
		                		$("#exName").val(data.name);
		                		$("#expertsTypeId").val(data.expertsType.id);
		                		$("#expertsTypeName").val(data.expertsType.name);		           
		                		$("#sex").val(data.sex).select2();		             
		                		$("#birthday").val(data.birthday);
		                		$("#bep").val(data.bep);
		                		$("#positional").val(data.positional);
		                		$("#phone").val(data.phone);
		                		$("#ageText").val(analyzeIDCard(card).age);
		                		$("#evaluateGrade").val(data.evaluateGrade).select2();
		                		$("#evaluateContent").val(data.evaluateContent);
		                		$("#remarks").val(data.remarks);
		                		attrDisabled();
		                	}else{
		                		if($("#exName").prop("disabled")){
		                			clearForm();
		                		}
		                		$("#card").val(card);
		                		$("#ageText").val(analyzeIDCard(card).age);		                
		                	}
		                	
		                }
		            });
				}else{
					if($("#exName").prop("disabled")){
            			clearForm();
            		}
					$("#card").val(card);
				}	
			});
		});
		
		function attrDisabled(){	
			$("#exName").attr("disabled",true);
    		$("#sex").attr("disabled",true);		             
    		$("#bep").attr("disabled",true);
    		$("#positional").attr("disabled",true);
    		$("#phone").attr("disabled",true);
    		$("#evaluateGrade").attr("disabled",true);
    		$("#evaluateContent").attr("disabled",true);
    		$("#remarks").attr("disabled",true);
		}
		
		function removeDisabled(){	
			$("#exName").attr("disabled",false);
    		$("#sex").attr("disabled",false);		             
    		$("#bep").attr("disabled",false);
    		$("#positional").attr("disabled",false);
    		$("#phone").attr("disabled",false);
    		$("#evaluateGrade").attr("disabled",false);
    		$("#evaluateContent").attr("disabled",false);
    		$("#remarks").attr("disabled",false);
		}
		
		function clearForm(){
			$('#addProExertsForm')[0].reset();
			$("#id").val("");
			$("#sex").val("").select2();	
			$("#evaluateGrade").val("").select2();
			removeDisabled();
		}
	</script>
</head>
<body>
	
	<form:form id="addProExertsForm" method="post" class="form-horizontal">
		<sys:message content="${message}"/>	
		<input type="hidden" name="lzdId" value="${lzdId}">	
		<input type="hidden" name="sectionId" value="${sectionId}">
		<input type="hidden" name="id" id="id">
		<div class="control-group" style="padding-top: 10px">
			<label class="control-label">专家姓名：</label>
			<div class="controls">
				<input name="name" maxlength="100" class="input-xlarge required zx-input" id="exName"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">身份证号码：</label>
			<div class="controls">
				<input name="card" id="card" maxlength="100" class="input-xlarge zx-input"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">分类：</label>
			<div class="controls">
				<sys:treeselect id="expertsType" name="expertsType.id" value="${expertsInfo.expertsType.id}" labelName="expertsType.name" labelValue="${expertsInfo.expertsType.name}" 
				title="专家分类" url="/zx/expertsType/treeData?type=2" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">性别：</label>
			<div class="controls">
				<%-- <form:input path="sex" htmlEscape="false" maxlength="1" class="input-xlarge "/> --%>
				<select name="sex" class="select2-offscreen" id="sex">
					<option value="1">男</option>
					<option value="2">女</option>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">生日：</label>
			<div class="controls">
				<input name="birthday" id="birthday" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate zx-input"					
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">参与评标专业：</label>
			<div class="controls">
				<input name="bep" maxlength="255" class="input-xlarge zx-input" id="bep"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">职称：</label>
			<div class="controls">
				<input name="positional" id ="positional" maxlength="100" class="input-xlarge zx-input"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<!-- <div class="control-group">
			<label class="control-label">学位：</label>
			<div class="controls">
				<input name="degree" maxlength="100" class="input-xlarge zx-input"/>
			</div>
		</div> -->
		<div class="control-group">
			<label class="control-label">手机号码：</label>
			<div class="controls">
				<input name="phone" maxlength="100" class="input-xlarge zx-input" id="phone"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">专家年龄：</label>
			<div class="controls">
				<input disabled="true" id="ageText" htmlEscape="false" maxlength="100" class="input-xlarge zx-input" />
				<label style="padding-left: 5px;padding-bottom: 2px;font-weight: bold;color: #ea5200;margin-left: 10px;">年龄会根据身份证号码自动算出</label>
			</div>
		</div>
		<!-- <div class="control-group">
			<label class="control-label">工作年限：</label>
			<div class="controls">
				<input name="workYear" maxlength="100" class="input-xlarge zx-input"/>
			</div>
		</div> -->
		<div class="control-group">
			<label class="control-label">专家评价：</label>
			<div class="controls">
				<select name="evaluateGrade" id="evaluateGrade">
					<c:forEach items="${fns:getDictList('evaluate_grade')}" var="e">
						<option value="${e.value}">${e.label}</option>
					</c:forEach>
				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">评价内容：</label>
			<div class="controls">
				<textarea name="evaluateContent" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge" id="evaluateContent"></textarea>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<textarea rows="4" class="input-xxlarge" maxlength="255" name="remarks" id="remarks"></textarea>
			</div>
		</div>
		<%-- <div class="control-group">
			<shiro:hasPermission name="zx:experts:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
		</div> --%>
	</form:form>
</body>
</html>